home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d4 / check6.arc / TURPROCS.TUR < prev    next >
Encoding:
Text File  |  1988-06-26  |  22.3 KB  |  638 lines

  1. {  SCREEN SCULPTOR(C)
  2.    (C) COPYRIGHT, THE SOFTWARE BOTTLING COMPANY OF NEW YORK, 1984
  3.    WARNING: Do not attempt to make any changes to this procedure unless you
  4.    have made a backup. The Software Bottling Company Of New York can not
  5.    and will not support such changes made to this program.
  6. ** Turbo Pascal Version, Trade Mark Of Borland International }
  7.  
  8. TYPE
  9.      RECPACKSS = record
  10.                  AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: INTEGER;
  11.                end;
  12.  
  13. VAR  regsSS : RECPACKSS;
  14.  
  15.  
  16. TYPE
  17.       video_pointerSS = array[1..3840] of CHAR;
  18. VAR
  19. { Video Variables  Set By SET_VIDEO_TYPE procedure in SETMON.TUR }
  20.       vcolorSS, voffSS, vonSS: byte; vdispSS: INTEGER; videoSS: ^video_pointerSS;
  21.  
  22. PROCEDURE BEEP(BeepOn: BOOLEAN);
  23. BEGIN
  24.   if BeepOn then write(chr(7));
  25. END;
  26.  
  27. { IF YOU HAVE VERSION 1 OF Turbo Pascal Then Replace The Following
  28.   COLOR & WRITEC PROCEDURES WITH THE CONTENTS OF 'COLORV1.TUR'
  29.   FILE
  30. }
  31.  
  32. PROCEDURE COLOR(foregr,backgr: BYTE);
  33. { Select current color by setting Foreground and Background
  34.   Any values between 0 and 15 are acceptable. See Tech Ref Manual
  35. }
  36.   BEGIN
  37.     if backgr>7 then foregr:=foregr+16;         { <======= TURBO Version 2}
  38.     TextColor(foregr); TextBackground(backgr);  { <======= TURBO Version 2}
  39.   END; { COLOR }
  40.  
  41. PROCEDURE WRITEC(vtext: STR80);
  42.   BEGIN
  43.     write(vtext);
  44.   END; { WRITEC }
  45.  
  46. PROCEDURE CLEAR_KBD;
  47. { Clear Type Ahead Characters From Keyboard }
  48. VAR kchar: CHAR;
  49. BEGIN
  50.   while keypressed do read(kbd,kchar);
  51. END; { CLEAR_KBD }
  52.  
  53. FUNCTION  SET_MONITOR_TYPE: INTEGER;
  54. { Determine The Type Of Monitor Being Used }
  55. VAR j : INTEGER;
  56.  
  57.   PROCEDURE CURSOR_SET;
  58.   { Set Cursor Size }
  59.   VAR v1,v2: INTEGER;
  60.   BEGIN
  61.   if j=2 then begin v1:=$3d4; v2:=$3d5 end
  62.   else begin v1:=$3b4; v2:=$3b5 end;
  63.   if (j=2) or (j=3) then
  64.   begin
  65.     port[v1]:=$0A; port[v2]:=0; { Set High Cursor Scan Line }
  66.     port[v1]:=$0B; port[v2]:=7; { Set Low Cursor Scan Line }
  67.   end;
  68.   END; { CURSOR_SET }
  69.  
  70. BEGIN
  71.   j:=mem[$40:$10]; { Figure out the monitor type }
  72.   j:=(j and $0030) DIV 16;
  73.   CASE j OF
  74.     0: begin writeln('Illegal Monitor Mode'); halt end;
  75.     1: begin { Set 40 column color to 80 column color }
  76.          writeln('Use MODE command to set to 80. ( MODE CO80 )'); halt
  77.        end;
  78.     2: videoSS:=ptr($b800,0);  { Graphics 80 }
  79.     3: videoSS:=ptr($b000,0);  { Monochrome }
  80.   END;
  81.   voffSS:=$1; vonSS:=$29; vdispSS:=$3d8;  { Video Off, On, Location }
  82.   CURSOR_SET; { Set To A Large Cursor }
  83.   COLOR(15,0); { Set Default Color }
  84.   SET_MONITOR_TYPE:=j;
  85. END; { SET_MONITOR_TYPE }
  86.  
  87. PROCEDURE DISPLAY_SCREEN(screen_name: str80; var exist: boolean);
  88. { Load Screen From Disk. Display To Monitor }
  89. VAR bload: array[1..3968] of CHAR;
  90.     scrname: FILE;
  91.  
  92.     PROCEDURE VIDEO_OFF; { Turn Video Off }
  93.       BEGIN port[vdispSS]:=voffSS; END;
  94.  
  95.     PROCEDURE VIDEO_ON; { Turn Video On }
  96.       BEGIN port[vdispSS]:=vonSS; END;
  97. BEGIN
  98.   assign(scrname,screen_name);  {$I-} reset(scrname); {$I+}
  99.   if IOresult=0 then
  100.   begin
  101.     exist:=TRUE; blockread(scrname,bload[1],filesize(scrname)); close(scrname);
  102.     VIDEO_OFF; move(bload[8],videoSS^,3840); VIDEO_ON;
  103.   end else exist:=FALSE;
  104. END; { DISPLAY_SCREEN }
  105.  
  106.  
  107. { See SCREEN SCULPTOR Manual For A Description Of GETITEM }
  108. PROCEDURE GETITEM(
  109.                   COL,LIN,LEN :         BYTE;
  110.                   ITYPE :               CHAR;
  111.               VAR WITEM :               STR80;
  112.                   PICT :                STR80;
  113.                   ITEM_LOW,ITEM_HIGH :  STR80;
  114.               VAR RET :                 STR2;
  115.                   RETRIEVE :            BOOLEAN;
  116.                   FGR_COLOR,BGR_COLOR : BYTE
  117.                   );
  118.  
  119. TYPE
  120.   PICT_TYPE = set of CHAR;
  121. CONST
  122.   confirm=FALSE; { If FALSE auto-skip to next field when field is filled }
  123.   l='K'; r='M'; u='H'; d='P'; dl='S'; ins='R'; pu='I'; pd='Q';
  124.       { Define The Function Keys }
  125.   f1=';'; f2='<'; f3='='; f4='>'; f5='?';
  126.   f6='@'; f7='A'; f8='B'; f9='C'; f10='D';
  127.   special_keys: PICT_TYPE = [l,r,u,d,dl,ins,pu,pd];
  128.   pict_elements: PICT_TYPE = ['X','U','L','#','9','8'];
  129.   bk: BYTE=8; esc: BYTE=27; cr: BYTE=13;
  130. VAR
  131.   hcol,pcol,tcol,pict_dec,item_dec,tempb1,tempb2,plen,ilen: BYTE;
  132.   kchar: str2; range_check,clear25: BOOLEAN;
  133.   check,end_of_field,begin_of_field,sign_flag,
  134.   special,dec_flag,valid_char: BOOLEAN;
  135.   temp_item, item: STR80;
  136.   fchar: CHAR;
  137.  
  138.  
  139. PROCEDURE FILLCHAR(var temp_item: STR80; tempb1: BYTE; fchar: CHAR);
  140. { Fills a variable with a number of fchar }
  141. VAR i: integer;
  142. BEGIN
  143. for i:=1 to tempb1 do temp_item[i]:=fchar; temp_item[0]:=chr(tempb1);
  144. END; { FILLCHAR PROCEDURE }
  145.  
  146.  
  147. FUNCTION DATE_CHECK(datevar: STR80): BOOLEAN;
  148. { Checks For Date Validity Excluding  the following:
  149.   Does not check Leap Years. If datevar is correct the DATE_CHECK is TRUE }
  150. CONST
  151.     month_days: array[1..12] of INTEGER=(31,28,31,30,31,30,31,31,30,31,30,31);
  152. VAR mm,dd,yy: STR2;
  153.     mmi,ddi,yyi: INTEGER;
  154.     error: INTEGER;
  155.     ch_date: BOOLEAN;
  156. BEGIN
  157. if ord(datevar[0])<>8 then
  158.   DATE_CHECK:=FALSE
  159. else
  160. begin
  161.   ch_date:=TRUE;
  162.   mm:=copy(datevar,1,2); dd:=copy(datevar,4,2); yy:=copy(datevar,7,2);
  163.   val(mm,mmi,error); if (error<>0) or (mmi<1) or (mmi>12) then ch_date:=FALSE;
  164.   if ch_date then
  165.   begin
  166.     val(dd,ddi,error);
  167.     if (error<>0) or (ddi<1) or (ddi>month_days[mmi]) then ch_date:=FALSE;
  168.   end;
  169.   if ch_date then
  170.   begin
  171.     val(yy,yyi,error); if error<>0 then ch_date:=FALSE;
  172.   end;
  173.   DATE_CHECK:=ch_date;
  174. end;
  175. END; { PROCEDURE DATE_CHECK }
  176.  
  177. FUNCTION CHECK_DATE(DATE, DATE_LOW, DATE_HIGH: STR80): BOOLEAN;
  178. { Check Validity If Date and whether it falls between low and high }
  179. { If low range date is higer than high range date then we assume }
  180. { we crossed centuries eg. 09/09/84 to 01/01/10 }
  181. { Also a null date is ignored }
  182. CONST dnull = '  /  /  ';
  183. VAR   ch_date: BOOLEAN;
  184. BEGIN
  185. if date<>dnull then ch_date:=DATE_CHECK(date) else ch_date:=TRUE;
  186. if ch_date and (date<>dnull) and (date_low<>dnull) and (date_high<>dnull) then
  187. begin
  188.   if ch_date then ch_date:=DATE_CHECK(date_low);
  189.   if ch_date then ch_date:=DATE_CHECK(date_high);
  190.   if ch_date then
  191.   begin
  192.     date:=copy(date,7,2)+copy(date,1,6);
  193.     date_low:=copy(date_low,7,2)+copy(date_low,1,6);
  194.     date_high:=copy(date_high,7,2)+copy(date_high,1,6);
  195.     if (date_low<=date_high) then             { Low Date < High Date }
  196.     begin
  197.        if (date<date_low) or (date>date_high) then ch_date:=FALSE
  198.     end else                                 { Low Date  > High Date }
  199.        if (date<date_low) and (date>date_high) then ch_date:=FALSE;
  200.   end;
  201. end;
  202. if ch_date then CHECK_DATE:=TRUE else begin CHECK_DATE:=FALSE; end;
  203. END; {PROCEDURE CHECK_DATE}
  204.  
  205. FUNCTION CHECK_RANGE(VAR item, item_low, item_high: STR80): BOOLEAN;
  206. { Check to see whether item is within and including low and high }
  207. VAR itemr, lowr, highr: REAL;
  208.     errori, errorl, errorh: INTEGER;
  209. BEGIN
  210. CHECK_RANGE:=TRUE;
  211. val(item_low,lowr,errorl); val(item_high,highr,errorh); val(item,itemr,errori);
  212. if (errorl=0) and (errorh=0) and (errori=0) then
  213. begin
  214.   if itemr<lowr then CHECK_RANGE:=FALSE
  215.   else if itemr>highr then CHECK_RANGE:=FALSE;
  216. end else
  217.   CHECK_RANGE:=FALSE;
  218. END; { PROCEDURE CHECK_RANGE }
  219.  
  220. PROCEDURE MESSAGE(mess_num: BYTE);
  221. { Displays A Message On Line 25 and sets global clear25 to TRUE }
  222. VAR mess, temp_item: STR79; mess_length: INTEGER;
  223. BEGIN
  224.   COLOR(0,7);
  225.   case mess_num of
  226.   1: mess:='Only 0 thru 9 Allowed';
  227.   2: mess:='Only 0 thru 9 or a space Allowed';
  228.   3: mess:='BAD Date OR Not Within '+item_low+' & '+
  229.             item_high+'. Use [Del] To Blank Out Digits.';
  230.   4: mess:='Number Not Within '+item_low+' & '+item_high+' Range';
  231.   5: mess:='Only 0 thru 9, decimal point OR - sign Allowed';
  232.   6: mess:='Only Y or N Allowed';
  233.   7: mess:='Only M or F Allowed';
  234.   8: mess:='No More Room For Digits. Use [Del] key to remove';
  235.   end; { case }
  236. mess_length:=ord(mess[0]);
  237. clear25:=TRUE;
  238. fillchar(temp_item,79-mess_length,' '); mess:=mess+temp_item;
  239. BEEP(BeepOnSS); gotoxy(1,25) ;writec(mess); gotoxy(hcol,lin);
  240. COLOR(FGR_COLOR, BGR_COLOR); CLEAR_KBD;
  241. END; {MESSAGE PROCEDURE}
  242.  
  243. FUNCTION  GETCHAR(ctype: CHAR; VAR kchar: STR2):BOOLEAN;
  244. { if GETCHAR=TRUE on return then kchar= (l r d u dl in pu pd esc cr bk)}
  245. { if GETCHAR=FALSE on return then kchar is alpha numeric chars }
  246. { ctype must be one of the following}
  247. { U=Uppercase, L=Lower Case, X=Any Char, 9=0..9,' ', #=0..9,-,+,. }
  248. { GETCHAR will filter out any control characters }
  249. TYPE  PICT_TYPE = set of CHAR;
  250. CONST esc = 27; cr = 13; bk = 8;
  251.       l='K'; r='M'; u='H'; d='P'; dl='S'; ins='R'; pu='I'; pd='Q';
  252.       f1=';';f2='<'; f3='='; f4='>'; f5='?';
  253.       f6='@'; f7='A'; f8='B'; f9='C'; f10='D';
  254.       special_keys: PICT_TYPE = [l,r,u,d,dl,ins,pu,pd];
  255.       func_keys: PICT_TYPE = [f1,f2,f3,f4,f5,f6,f7,f8,f9,f10];
  256. var   str: CHAR; special,correct: BOOLEAN;
  257.       temps: STR79;
  258. BEGIN
  259.   kchar:='';
  260.   GETCHAR:=TRUE; correct:=FALSE;
  261.   repeat { until getchar = TRUE }
  262.   special:=TRUE;
  263.   repeat { until a valid picture character }
  264.   repeat until keypressed;
  265.   read(kbd,kchar[1]);
  266.   if keypressed and (kchar[1]=chr(esc)) then
  267.   begin
  268.     read(kbd,kchar[2]); kchar[1]:=chr(0);kchar[0]:=chr(2);
  269.   end else
  270.     kchar[0]:=chr(1);
  271. { Clear Line 25 }
  272.   if clear25 then
  273.   begin
  274.     fillchar(temps,79,' ');
  275.     color(7,0); gotoxy(1,25); writec(temps); gotoxy(hcol,lin);
  276.     clear25:=FALSE; color(FGR_COLOR, BGR_COLOR);
  277.   end;{ Clear Line }
  278.   if (not (ord(kchar[1]) in [esc,cr,bk])) and (ord(kchar[0])=1) then
  279.   begin
  280.   str:=kchar[1];
  281.   if (str>=' ') and (str<='~') then
  282.   case ctype of
  283.     'X': correct:=TRUE;
  284.     'U': begin
  285.          if str in ['a'..'z'] then str:=chr(ord(str) and $df);
  286.          kchar[1]:=str; correct:=TRUE;
  287.          end;
  288.     'L': begin
  289.          if str in ['A'..'Z'] then  str:=chr(ord(str) or $20);
  290.          kchar[1]:=str; correct:=TRUE;
  291.          end;
  292.     '#': if  (str in ['0'..'9','-','.']) then correct:=TRUE else message(5);
  293.     '9': if str in ['0'..'9',' '] then correct:=TRUE else message(2);
  294.     '8': if str in ['0'..'9'] then correct:=TRUE else message(1);
  295.   end { case  }
  296.   end { begin }
  297.   else
  298.     begin {special character}
  299.       GETCHAR:= FALSE; correct:=TRUE; str:=kchar[1];
  300.     end;
  301.   until correct;
  302.   if (ord(kchar[0])=2) then  { see if it is a special character }
  303.   begin
  304.     special:=FALSE;
  305.     GETCHAR:=TRUE;
  306.     if (kchar[2] in special_keys) or (kchar[2] in func_keys) then
  307.     begin
  308.       GETCHAR:=FALSE; special:=TRUE;
  309.     end else BEEP(BeepOnSS);
  310.   end;
  311.   until special;
  312.   ret:=kchar;
  313. END; { GETCHAR FUNCTION }
  314.  
  315. PROCEDURE DECH; { Positions Cursor At the Next Non Edit Character }
  316. VAR elem_end: BOOLEAN; tempb1: BYTE;
  317. BEGIN
  318. if hcol<>(col+tcol-1) then
  319. begin
  320.   tempb1:=pcol; elem_end:=FALSE;
  321.   repeat
  322.     tempb1:=tempb1-1;if (pict[tempb1] in pict_elements) or (tempb1<1) then elem_end:=TRUE;
  323.   until elem_end;
  324.   if tempb1>=1 then begin hcol:=hcol-(pcol-tempb1);pcol:=tempb1;end;
  325. end else
  326. begin_of_field:=TRUE;
  327. END; { DECH PROCEDURE }
  328.  
  329. PROCEDURE INCH; { Positions Cursor At the Next Non Edit Character }
  330. VAR elem_end: BOOLEAN; tempb1: BYTE;
  331. BEGIN
  332. if hcol<>(col+len-1) then
  333. begin
  334.   tempb1:=1; elem_end:=FALSE;
  335.   repeat
  336.     tempb1:=tempb1+1;
  337.     if (pict[pcol+tempb1-1] in pict_elements) or ((pcol+tempb1)>(len)) then elem_end:=TRUE;
  338.   until elem_end;
  339.   if tempb1<=(len) then  begin hcol:=hcol+tempb1-1; pcol:=pcol+tempb1-1; end;
  340. end else
  341. end_of_field:=TRUE;
  342. END; { INCH PROCEDURE }
  343.  
  344. PROCEDURE STRIP_BLANKS(VAR temp_item: STR80);
  345. { Strip Blanks On Both Sides Of passed item }
  346. VAR i,j: BYTE;
  347. BEGIN
  348. if temp_item<>'' then
  349. begin
  350.   j:=ord(temp_item[0]);
  351.   { Strip Leading Blanks }
  352.   i:=0; while (temp_item[i+1]=' ') and (i<j) do i:=i+1; { strip leading blanks }
  353.   if (i>0) and (i<j) then temp_item:=copy(temp_item,i+1,j-i)
  354.   else if (i=j) and (temp_item[j]=' ') then temp_item:='';
  355.   i:=pos(' ',temp_item); { strip trailing blanks }
  356.   if i<>0 then temp_item:=copy(temp_item,1,i-1);
  357. end;
  358. END; { STRIP_BLANKS PROCEDURE }
  359.  
  360. BEGIN { Main Procedure Of GETITEM }
  361. item:=witem;   { Store Actual Item In A Work Variable }
  362. clear25:=FALSE;
  363. if itype='D' then begin pict:='88/88/88'; len:=8; end;
  364. if itype='Y' then
  365. begin
  366.   if not (item[1] in ['Y','N']) then item:='Y'; pict:='U'; len:=1;
  367. end;
  368. if itype='M' then
  369. begin
  370.   if not (item[1] in ['M','F']) then item:='M'; pict:='U'; len:=1;
  371. end;
  372. end_of_field:=FALSE; begin_of_field:=FALSE;
  373. if (pict='') and (itype='C') then pict:='X';
  374. plen:=ord(pict[0]); fchar:=pict[plen]; ilen:=ord(item[0]);
  375. {* Fill Item with blanks  *}
  376. if itype<>'N'  then {* If item is non numeric *}
  377. begin
  378.   while ilen<len do  begin    item:=item+' '; ilen:=ilen+1;  end;
  379.   while plen<len do  begin    pict:=pict+fchar; plen:=plen+1;  end;
  380. end else {* If item is numeric *}
  381. begin
  382.   strip_blanks(item);
  383.   if item='' then item:='0'; ilen:=ord(item[0]);
  384.   while ilen<len do  begin item:=' '+item; ilen:=ilen+1; end;
  385.   while plen<len do  begin pict:='#'+pict; plen:=plen+1; end;
  386.   if ord(pict[0])>len then pict:=copy(pict,ord(pict[0])-len+1,len);
  387.   if ord(item[0])>len then item:=copy(item,1,len);
  388.   ilen:=ord(item[0]); plen:=ord(pict[0]);
  389.   pict_dec:=pos('.',pict); item_dec:=pos('.',item);
  390. { Align Decimal Positions If Necessary }
  391. if pict_dec<>item_dec then
  392. begin { alignement }
  393. check:=TRUE;
  394. if (pict_dec=0) and check then { If picture has no decimal point and item does}
  395. begin
  396.   item:=copy(item,1,item_dec-1); fillchar(temp_item,ord(pict[0])-ord(item[0]),' ');
  397.   item:=temp_item+item; check:=FALSE;
  398. end;
  399. if (item_dec=0) and check then { If item has no decimal point and pict does}
  400. begin
  401.   strip_blanks(item);
  402.   tempb2:=plen-pict_dec; { # of decimal points };
  403.   fillchar(temp_item,tempb2,item[ord(item[0])]);
  404.   item:=item+'.'+temp_item; { Add decimal trailing digits }
  405.   ilen:=ord(item[0]); { Get length of item }
  406.   while ilen<plen do begin item:=' '+item; ilen:=ilen+1; end; { Add blanks left}
  407.   if ilen>plen then { If The Item > Picture }
  408.   begin
  409.     item:=copy(item,1,pict_dec-1); item:=item+'.'+temp_item;
  410.   end;
  411.   check:=FALSE;
  412. end;
  413. if (item_dec>pict_dec) and check then { If item decimal is further right than pict dec}
  414. begin { Move the item to the left dropping off numbers  picts}
  415.   plen:=ord(pict[0]); ilen:=ord(item[0]);
  416.   item:=copy(item,item_dec-pict_dec+1,ilen-(item_dec-pict_dec));
  417.   ilen:=ord(item[0]); tempb1:=plen-ord(item[0]);
  418.   fillchar(temp_item,tempb1,item[ilen]); item:=item+temp_item;
  419.   ilen:=ord(item[0]);
  420.   while ilen<plen do begin item:=' '+item; ilen:=ilen+1; end; { Add blanks left}
  421.   check:=FALSE;
  422. end;
  423. if (pict_dec>item_dec) and check then { If pict decimal is further right than item's}
  424. begin
  425.   tempb2:=plen-pict_dec; item:=copy(item,1,item_dec+tempb2); ilen:=ord(item[0]);
  426.   while ilen<len do begin item:=' '+item; ilen:=ilen+1; end; check:=FALSE;
  427. end;
  428. end { alignement };
  429. end { fillings};
  430. {* Copy edit characters to item *}
  431.   for tempb1:=1 to len do
  432.     if not (pict[tempb1] in pict_elements) then item[tempb1]:=pict[tempb1];
  433. {* Display The item on the screen *}
  434.   color(FGR_COLOR, BGR_COLOR);
  435.   gotoxy(col,lin); writec(item);
  436. {* Get Data From Screen If Retrieve is True}
  437. if retrieve then
  438. begin { Retrieve }
  439. {* Move cursor to first position by bypassing edit chars }
  440.   pcol:=1;
  441.   while (not (pict[pcol] in pict_elements)) and (pcol<=len) do  pcol:=pcol+1;
  442. {* Readjust column }
  443.   tcol:=pcol;
  444. {* Handle Non Numeric Type Of Item *}
  445. if (itype<>'N') and (pcol<=len) then  { pcol is position of cursor within field}
  446. begin {* Non Numeric Field *}
  447.   repeat { Until range_check = TRUE }
  448.   pcol:=tcol; hcol:=col+pcol-1;  gotoxy(hcol,lin); {* Go to location on screen*}
  449.   repeat
  450.     end_of_field:=FALSE; begin_of_field:=FALSE; special:=FALSE;
  451.     if getchar(pict[pcol],kchar) then
  452.     begin
  453.       writec(kchar);item[pcol]:=kchar[1]; inch; gotoxy(hcol,lin);
  454.     end else
  455.     special:=TRUE;
  456.     if special then
  457.     begin { Special Key Pressed }
  458.       ret:=kchar; special:=FALSE;
  459.       if kchar[1]=chr(bk) then { It is backspace }
  460.       begin
  461.         dech; gotoxy(hcol,lin);  {Left}
  462.       end else
  463.       if (ord(kchar[0])=2) and (kchar[2] in [l,r,dl,ins]) then
  464.       begin
  465.         case kchar[2] of
  466.        l: begin dech; gotoxy(hcol,lin); end; {Left}
  467.        r: begin inch; gotoxy(hcol,lin); end; {Right}
  468.       dl: begin {Delete}
  469.             tempb2:=pcol+1; {FInd where the next edit char starts}
  470.             while (pict[tempb2] in pict_elements) and (tempb2<=len) do
  471.             tempb2:=tempb2+1; tempb2:=tempb2-1; { tempb1=start, tempb2:=end}
  472.             for tempb1:=pcol to tempb2-1 do {move chars left}
  473.             begin { & put blank at end} item[tempb1]:=item[tempb1+1]; end;
  474.             item[tempb2]:=' ';
  475.             {rewrite the item}
  476.             gotoxy(col,lin);writec(item);gotoxy(hcol,lin);
  477.           end;
  478.      ins: begin {Insert}
  479.             tempb2:=pcol+1;
  480.             while (pict[tempb2] in pict_elements) and (tempb2<=len) do tempb2:=tempb2+1;
  481.             tempb2:=tempb2-1;
  482.             for tempb1:=tempb2 downto pcol+1 do
  483.             begin item[tempb1]:=item[tempb1-1]; end;
  484.             item[pcol]:=' '; gotoxy(col,lin);writec(item);gotoxy(hcol,lin);
  485.           end;
  486.           end { Case kchar };
  487.         end
  488.         else {esc,cr,pgup,pgdn,up,dn}
  489.         special:=TRUE;
  490.       end {If backspace };
  491.       if end_of_field or begin_of_field then BEEP(BeepOnSS);
  492.     until (end_of_field and (not confirm)) or begin_of_field or special;
  493.     tempb1:=len; { Strip Trailing Blanks }
  494.     if itype='C' then
  495.       while (item[tempb1]=' ') and (tempb1>0) do tempb1:=tempb1-1;
  496.     item[0]:=chr(tempb1); range_check:=TRUE;
  497.     if itype='D' then
  498.     begin
  499.       range_check:=check_date(item,item_low,item_high);
  500.       if not range_check then message(3);
  501.     end;
  502.     if itype='Y' then
  503.       if not (item[1] in ['Y','N']) then
  504.       begin
  505.         range_check:=FALSE; message(6);
  506.       end;
  507.     if itype='M' then
  508.       if not (item[1] in ['M','F']) then
  509.       begin
  510.         range_check:=FALSE; message(7);
  511.       end;
  512.   until range_check;
  513.   end  { If non numeric type of item} else { if Numeric }
  514. if (itype='N') then
  515. begin
  516.   tcol:=len;
  517.   repeat { Until range_check=TRUE }
  518.   len:=tcol;
  519.   tempb1:=len; len:=pos('.',item); range_check:=FALSE;
  520.   if len=0 then len:=tempb1 else len:=len-1;{ Item has decimal point }
  521.   hcol:=col+len-1; pcol:=len; gotoxy(hcol,lin);
  522.   special:=FALSE;  sign_flag:=FALSE;  end_of_field:=FALSE;  dec_flag:=FALSE;
  523.   repeat
  524.     valid_char:=FALSE;
  525.     if getchar('#',kchar) then
  526.     begin { Not Special }
  527.     case kchar of
  528. '-' : { Sign } if not sign_flag then valid_char:=TRUE;
  529. '.' :  { Decimal point }
  530.      if (len<>tempb1) and (not dec_flag) then
  531.      begin
  532.        hcol:=hcol+2; pcol:=len+2; gotoxy(hcol,lin);
  533.        dec_flag:=TRUE; sign_flag:=TRUE;
  534.      end;
  535. '0'..'9': valid_char:=TRUE;
  536.      end { Case kchar };
  537.      { sign_flag = if FALSE we allow minus (-) sign }
  538.      { dec_flag = if FALSE we allow decimal (.) point }
  539.      if (valid_char) and (not dec_flag) then { Integer Portion }
  540.      begin
  541.        if (item[1]<>' ') and (len<>tempb1) and (sign_flag) then
  542.          message(8) { Overflow Numeric Field }
  543.        else
  544.        begin
  545.          if  (not sign_flag)  then  { Erase Old Entry. Start New One }
  546.          begin                      { Sign Allowed }
  547.            for pcol:=1 to len-1 do item[pcol]:=' ';
  548.            if tempb1>len then
  549.               for pcol:=len+2 to tempb1 do item[pcol]:='0';
  550.            item[len]:=kchar; gotoxy(col,lin);
  551.            writec(item); gotoxy(hcol,lin);
  552.            if kchar[1]<>'0' then sign_flag:=TRUE;
  553.          end else
  554.          begin
  555.            { Insert A Digit. No Sign Allowed }
  556.            if not end_of_field then
  557.              for pcol:=1 to len-1 do item[pcol]:=item[pcol+1];
  558.            item[len]:=kchar; gotoxy(col,lin); writec(item); gotoxy(hcol,lin);
  559.          end;
  560.          if (item[1]<>' ') and (len=tempb1) then end_of_field:=TRUE;
  561.        end;
  562.      end { Integer Portion }
  563.      else { Decimal Portion }
  564.        if valid_char and (sign_flag) then
  565.        begin
  566.          item[pcol]:=kchar[1]; writec(item[pcol]);
  567.          if not end_of_field then begin hcol:=hcol+1; pcol:=pcol+1 end;
  568.          if pcol>tempb1 then
  569.          begin hcol:=hcol-1; pcol:=pcol-1; end_of_field:=TRUE end;
  570.          gotoxy(hcol,lin);
  571.        end;
  572.      end { getchar is FALSE } else { getchar is TRUE }
  573.    special:=TRUE;
  574. { Special Keys. DEL}
  575.    if special then
  576.    begin
  577.      ret:=kchar; special:=FALSE;
  578.      if (ord(kchar[0])=2) then
  579.      begin { Case }
  580.      case kchar[2] of
  581.  dl,l:{ DELETE KEY PRESSED OR LEFT ARROW KEY }
  582.        case dec_flag of
  583.   False: { Integer Portion }
  584.        begin
  585.          sign_flag:=TRUE;
  586.          for pcol:=len downto 2 do item[pcol]:=item[pcol-1];
  587.          if (item[len] in [' ','-']) then
  588.          begin item[len]:='0'; sign_flag:=FALSE; end;
  589.          item[1]:=' '; gotoxy(col,lin); writec(item);
  590.          gotoxy(hcol,lin);
  591.          end_of_field:=FALSE;
  592.        end { F };
  593.    True: { Decimal Portion }
  594.    { Put 0 @ Cursor. Check If Going To Integer Part}
  595.        if pict[pcol-1]='.' then  {Are We In Integer Part?}
  596.        begin {YES. Initialize Variables}
  597.          hcol:=col+len-1; gotoxy(hcol,lin); dec_flag:=FALSE;
  598.          end_of_field:=FALSE;
  599.        end else
  600.        begin
  601.          if not end_of_field then begin hcol:=hcol-1; pcol:=pcol-1 end;
  602.          gotoxy(hcol,lin);item[pcol]:='0'; writec(item[pcol]); gotoxy(hcol,lin);
  603.          end_of_field:=FALSE;
  604.        end;
  605.        { T }
  606.      end { dec_flag CASE };
  607. u,d,l,r,pu,pd,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10: special:=TRUE;
  608.    end; { DELETE KEY CASE }
  609.   end { Case } else
  610.   if (ord(kchar[1]) in [cr, esc]) then special:=TRUE;
  611. end { Special };
  612. if end_of_field and (not special) then BEEP(BeepOnSS);
  613. until special or (end_of_field and (not confirm));
  614. pcol:=pos('.',pict);
  615. if (item[len] in [' ','-']) and (pcol=0) then
  616.   begin  item[len]:='0';gotoxy(col,lin);writec(item);end
  617. else
  618. if (pcol>0) and (item[pcol-1] in [' ','-']) then
  619.   begin  item[pcol-1]:='0'; gotoxy(col,lin);writec(item);end;
  620. temp_item:=item;
  621. strip_blanks(item);
  622. range_check:=check_range(item,item_low,item_high);
  623. if not range_check then begin message(4); item:=temp_item; end;
  624. until range_check;
  625. end;{ Numeric }
  626. end { Retrieve } else
  627. begin
  628.   if itype='N' then strip_blanks(item);
  629.   if itype='C' then
  630.   begin
  631.     tempb1:=len; { Strip Trailing Blanks }
  632.     while (item[tempb1]=' ') and (tempb1>0) do tempb1:=tempb1-1;
  633.     item[0]:=chr(tempb1);
  634.   end;
  635. end;
  636. witem:=item; { Return result Back To witem }
  637. END;{ GETITEM PROCEDURE}
  638.